package com.woniuxy.classteacher.controller;

import com.woniuxy.classteacher.service.StudentDataAnalyzeService;
import com.woniuxy.commons.entity.ResponseEntity;
import com.woniuxy.commons.exception.BzeducationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Auther: 牟强
 * @Date: 2020/7/30/030 16:12
 * @Description:
 */
@RestController
public class StudentDataAnalyzeController extends BzeducationException {
    @Autowired
    private StudentDataAnalyzeService studentDataAnalyzeService;

    /**
     * @Author: 牟强
     * @Date: 2020/8/5/005 16:24
     * @Description: 初始化学生年级排名数据界面
     * @Param: [request]
     * @return: com.woniuxy.commons.entity.ResponseEntity<java.util.Map < java.lang.String, java.lang.Object>>
     */
    @GetMapping("/initAnalyze")
    public ResponseEntity<Map<String, Object>> initDataAnalyze(HttpServletRequest request) {
        ResponseEntity<Map<String, Object>> responseEntity = new ResponseEntity<>();
        Map<String, Object> map = studentDataAnalyzeService.initStudentRankingChart(request);
        responseEntity.setCode(ResponseEntity.SUCCESS);
        responseEntity.setData(map);
        return responseEntity;
    }

    /**
     * @Author: 牟强
     * @Date: 2020/8/5/005 16:25
     * @Description: 分析出来的数据
     * @Param: [teamId, gradeName, request]
     * @return: com.woniuxy.commons.entity.ResponseEntity<java.util.Map < java.lang.String, java.lang.Object>>
     */
    @GetMapping("/acquireData")
    public ResponseEntity<Map<String, Object>> studentRankingChart(Integer teamId, String gradeName, HttpServletRequest request) {
        ResponseEntity<Map<String, Object>> responseEntity = new ResponseEntity<>();
        Map<String, Object> map = studentDataAnalyzeService.studentRankingChart(teamId, gradeName, request);
        responseEntity.setData(map);
        responseEntity.setCode(ResponseEntity.SUCCESS);
        return responseEntity;
    }
}
